Images acquired using a digital camera or image sensor may be grainy and erroneously pixilated. Even high resolution images may exhibit graininess due, in part, to noise. The graininess of an image due to noise may be reduced using a sigma filter. A sigma filter is used to smooth an image, reducing the graininess of the image, while maintaining sharp edges within the image. A sigma filter functions by replacing the value of a pixel with an average of selected pixels from within a window of pixels. The window of pixels is defined relative to a center pixel. The center pixel is the pixel whose value is to be replaced by the average pixel value of the selected pixels. The selected pixels are those pixels within the window that differ in value from the value of the center pixel by no more than a sigma value. Pixels that differ in value from the value of the center pixel by at least the sigma value are not used to determine the average pixel value. In this way, pixels are smoothed by similarly valued pixels, and edges or other high-contrast boundaries in the image are preserved instead of being averaged or smoothed by the sigma filter.
An example of sigma filtering is illustrated in FIG. 1A. In FIG. 1A, a 3×3 block 10 or window of pixels is illustrated. A center pixel PC is in the center of the 3×3 block 10. The other pixels in the 3×3 block 10 include pixels P1, P2, P3, P4, P5, P6, P7, P8. Each of pixels P1, P2, P3, P4, P5, P6, P7, P8 and center pixel PC represent like-colored pixels. For example, center pixel PC may represent a red pixel. Pixel P4, then, represents the red pixel closest to the left of center pixel PC. It is understood that other pixels of different colors may be interspersed between the pixel P4 and the center pixel PC. Only pixels of like-color are considered with relation to center pixel PC. In FIG. 1B, the pixels in block 10 are illustrated with example pixel values in relation to the value of the center pixel PC. The example pixel values represent eight-bit pixel values, and hence range from 0 to 255. For example, in FIG. 1B, the value of pixel P1 is equal to the value of the center pixel PC plus 24 (i.e., P1=PC+24). For example purposes only, P2=PC+5, P3=PC+10, P4=PC+31, P5=PC−22, P6=PC−4, P7=PC−1, and P8=PC+2. If the sigma value for pixel PC is equal to seven, then only those pixels within block 10 with values that differ from the value of the center pixel PC by less than seven are considered in determining a new average value for the center pixel PC. In the example of FIG. 1B, the only pixels in block 10 that are considered for the new average are pixels P2, PC, P6, P7 and P8. Thus, the new value of the center pixel PC is equal to the average value of pixels PC, P2, P6, P7 and P8, as illustrated in Equation 1.PC|new=(PC+P2+P6+P7+P8)/5  Equation 1.
In the sigma filter, the degree of filtering is controlled by the sigma value. Generally, the sigma value used depends on the magnitude of the center pixel PC and increases as the value of the center pixel PC also increases. The sigma threshold function used to determine the sigma value is a characteristic of the image sensor used to create the image. By modifying the function so that the sigma value is increased, the amount of filtering in an image is also increased. However, if the sigma value is increased too much, high-contrast edges in the images will be smoothed and lost.
Additionally, in the sigma filter, the size of the window around the center pixel PC is identified as the filter kernel. Increasing the size of the filter kernel increases the number of pixel elements available for averaging. However, this also increases the number of computations required to evaluate the window. Therefore, increasing the size of the filter kernel becomes, at some point, impractical. On the other hand, reducing the size of the filter kernel also reduces the effectiveness of the sigma filter. A 5×5 pixel kernel is often used for the sigma filter.
The degree of filtering that may be used on an image depends on the image itself. A feature-rich image which includes a high level of detail that must be preserved must be carefully filtered so as to not lose any important details. On the other hand, a “flat,” featureless image can be broadly filtered. A sigma filter can be used to filter both feature-rich and flat images, though it is desirable to use a broader filter to filter flat regions. Therefore, there is a need for an image filter that can filter flat regions of images more effectively than a conventional sigma filter.